//
//  YTFEmotionButton.swift
//  sinaWeibo
//
//  Created by pro on 16/3/9.
//  Copyright © 2016年 pro. All rights reserved.
//

import UIKit

class YTFEmotionButton: UIButton {

    var emotion: YTFEmotion?{
    
        didSet{
            
            //对这个button进行赋值
            //判断是显示图片表情还是emoji
            if let png = emotion?.png {
                
                //获取图片的绝对路径,注意路径的正确性
                let imagePath = "\(emotion!.path!)/\(png)"
                //                    print(imagePath)
                
                //设置按钮图片
                self.setImage(UIImage(named: imagePath), forState: UIControlState.Normal)
                self.setTitle(nil, forState: UIControlState.Normal)
                
                //使用的时候显示
                self.hidden = false
            }
            
            if let emoji = emotion?.emoji {
                
                self.setImage(nil, forState: UIControlState.Normal)
                
                self.setTitle(emoji, forState: UIControlState.Normal)
                
                self.titleLabel?.font = UIFont.systemFontOfSize(35)
                //使用的时候显示
                self.hidden = false
                
            }

        
        }
        
    }

}
